export function addWaterMark(url) {
    const shaderCode = `#version 300 es
        precision highp float;
        precision highp sampler2D;

        layout(location = 0) out vec4 FragColor;

        in vec2 v_textureCoordinates;

        uniform sampler2D imageTexture;       
        uniform sampler2D colorTexture;      
        uniform vec4 czm_viewport;
        uniform vec2 imageSize;

        void main()
        {
            vec2 uv = v_textureCoordinates;
            vec2 resolution = czm_viewport.zw;
            vec2 fragPixel = uv * resolution;
            vec2 imgUv = vec2(imageSize.x / resolution.x, imageSize.y / resolution.y);

            bool inRange = fragPixel.x <= imageSize.x && fragPixel.y <= imageSize.y;
            vec4 color = texture(colorTexture, uv);
            vec4 imgColor = texture(imageTexture, uv / imgUv);
                imgColor = mix(color, imgColor, imgColor.a);
            vec4 mixColor = inRange  ? imgColor : color;
            FragColor = mixColor;
        }
    `;
    var fields = new Li.StringVector();
    const material = new Li.Material();
    material.shaderProgram = Li.ShaderProgram.createViewportQuadShader(
        shaderCode,
        fields
    );
    fields.delete();
    const postProcess = new Li.PostProcess();
    postProcess.material = material;
    GlobalViewer.renderSystem.addPostProcess(postProcess);

    let texImage = new Li.TextureImage();
    let imgWidth = 206;
    let imgHeight = 47;
    texImage.loadImage(url);
    texImage.width = imgWidth;
    texImage.height = imgHeight;
    let tex = new Li.Texture();
    tex.addTextureImage(texImage);

    GlobalViewer.addEventListener("update", function () {
        material.setParameterVec2(
            "imageSize",
            Li.Vector2.create(imgWidth, imgHeight)
        );
        material.setParameterTex("imageTexture", tex);
    });
}
